//
//  MainDetailViewController.m
//  SimpleTimeDemo
//
//  Created by lanou3g on 15/11/14.
//  Copyright © 2015年 王丽珍. All rights reserved.
//

#import "MainDetailViewController.h"
#import "MainDataHelper.h"
#import "MainModel.h"

@interface MainDetailViewController ()

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation MainDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadWebView];
}

- (void)loadWebView
{
    _webView = [[UIWebView alloc] initWithFrame:self.view.frame];
    
    [self.view addSubview:_webView];
    
    NSString *string = @"http://api2.pianke.me/article/info";
    NSString *bodyString = [NSString stringWithFormat:@"auth=W8Um3Eiixm3qtDC8h8GcDrlDJxQMeoN76M8GxpD2Qm3cWP22NFFQx1a7Ps&client=1&contentid=%@&deviceid=70D20EF9-AB8B-42FD-937C-7D884DB58895&version=3.0.6",_webStr];
    [MainDataHelper postDataWithUrlString:string andBodyString:bodyString compare:^(id object) {
        NSDictionary *dic = object;
        MainModel *model = [[MainModel alloc] init];
        model.html = dic[@"data"][@"html"];
        NSLog(@"html===%@",model.html);
        //        _contentLabel.numberOfLines = 0;
        //        [_contentLabel sizeToFit];
        //        _contentLabel.text = model.html;
        
        [_webView loadHTMLString:model.html baseURL:nil];
        
    }];
    
    //        NSURL *url = [NSURL URLWithString:@"http://api2.pianke.me/article/info"];
    //        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    //        [request setHTTPMethod:@"POST"];
    //
    //        NSString *body = [NSString stringWithFormat:@"auth=W8Um3Eiixm3qtDC8h8GcDrlDJxQMeoN76M8GxpD2Qm3cWP22NFFQx1a7Ps&client=1&contentid=%@&deviceid=70D20EF9-AB8B-42FD-937C-7D884DB58895&version=3.0.6",_webStr];
    //
    //
    //        NSData *data = [body dataUsingEncoding:NSUTF8StringEncoding];
    //        [request setHTTPBody:data];
    //
    //        [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
    //    
    //        self.webView.delegate = self;
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
